//
//  MLStage2.m
//  WaterProof
//
//  Created by victor0321 on 12/1/4.
//  Copyright 2012年 __MyCompanyName__. All rights reserved.
//

#import "MLStage2.h"
#define PTM_RATIO 32
#define BLUR_R 10
@interface MLStage2()
-(void) runWaterEffect;                             // produce the water
-(void) runSmokeEffect;


//-(void) checkPipe;
@end


@implementation MLStage2

-(id) init
{
	if ((self = [super init]))
	{
		CCLOG(@"===========================================");
        CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
        screenSize = [CCDirector sharedDirector].winSize;
        CCLabelTTF* test = [CCLabelTTF labelWithString:@"StageTwo" fontName:@"GeezaPro" fontSize:128];
        test.position = ccp(screenSize.width/2, screenSize.height/2);
        [self addChild:test];
    
        self.isTouchEnabled = YES;
        
        [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"backGround2.mp3" loop:YES];
        CCSprite* background = [CCSprite spriteWithFile:@"OurHome.png"];
        background.position = CGPointMake(screenSize.width / 2, screenSize.height / 2);
        [self addChild:background];
        
       // Particle system
       // [self runWaterEffect];
       // [self runSmokeEffect];
        for (int i = 0; i < GRID_MAX_WIDTH; i++) {
            if (i % 2 == 0) leakWaterLocation[i] = true;
        }
        
    }
    return self;
}

-(bool*) getleakWaterArray{
    return leakWaterLocation;
}

-(void) runSmokeEffect{
    smoke = [MLMyParticleSystem particleWithFile:@"smokeSi1.plist"];
    //CGSize winSize = [[CCDirector sharedDirector] winSize];
    smoke.position = CGPointMake(200, 200);
    //smoke.duration = 2;
    smoke.totalParticles = 300;// Can change the flow of water
    //water.positionType=kCCPositionTypeGrouped;
    
    [self addChild:smoke z:1 tag:2];
}
-(void) runWaterEffect{
    
    water = [MLMyParticleSystem particleWithFile:@"waterSi2.plist"];
    CGSize winSize = [[CCDirector sharedDirector] winSize];
    water.position = CGPointMake(winSize.width / 2, winSize.height);
    water.duration=2;
    water.totalParticles = 200;// Can change the flow of water
    //water.positionType=kCCPositionTypeGrouped;
    //checkPipe(pipeLocation, pipeRoute);
   // [self addChild:water z:1 tag:2];
    
}

-(void) dealloc
{
	CCLOG(@"===========================================");
    CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
	
	// always call [super dealloc] at the end of every dealloc method
	[super dealloc];
}


@end
